@(pageName: Option[String],
  commits: List[gitbucket.core.util.JGitUtil.CommitInfo],
  repository: gitbucket.core.service.RepositoryService.RepositoryInfo,
  isEditable: Boolean)(implicit context: gitbucket.core.controller.Context)
@import gitbucket.core.view.helpers
@gitbucket.core.html.main(s"History - ${repository.owner}/${repository.name}", Some(repository)){
  @gitbucket.core.html.menu("wiki", repository){
    @if(isEditable) {
      <div class="pull-right">
        @if(pageName.isEmpty) {
          <a class="btn" href="@helpers.url(repository)/wiki/_new">New Page</a>
        } else {
          <a class="btn btn-default" href="@helpers.url(repository)/wiki/@helpers.urlEncode(pageName)/_edit">Edit Page</a>
          <a class="btn btn-success" href="@helpers.url(repository)/wiki/_new">New Page</a>
        }
      </div>
    }
    <h1 class="body-title">
    @if(pageName.isEmpty){
      <span class="muted">History</span>
    } else {
      <span class="muted">History for</span> @pageName.get
    }
    </h1>
    <table class="table table-bordered">
      <thead>
        <tr>
          <th colspan="3">
            <div class="pull-left" style="padding-top: 4px;">Revisions</div>
            <div class="pull-right">
              <input type="button" id="compare" value="Compare Revisions" class="btn btn-sm btn-default"/>
            </div>
          </th>
        </tr>
      </thead>
      <tbody>
      @commits.map { commit =>
        <tr>
          <td style="width: 32px; text-align: center ;"><input type="checkbox" name="commitId" value="@commit.id" aria-label="Revision"></td>
          <td style="width: 200px;">@helpers.avatarLink(commit, 20)&nbsp;@helpers.user(commit.authorName, commit.authorEmailAddress)</td>
          <td>
            <span class="muted">@gitbucket.core.helper.html.datetimeago(commit.authorTime):</span>&nbsp;@commit.shortMessage
          </td>
        </tr>
      }
      </tbody>
    </table>
    <script>
    $(function(){
      $('input[name=commitId]').click(function(){
        return !($('input[name=commitId]:checked').length == 3);
      });

      $('#compare').click(function(){
        var e = $('input[name=commitId]:checked');
        if(e.length == 2){
          @if(pageName.isEmpty){
            location.href = '@helpers.url(repository)/wiki/_compare/' +
              $(e.get(1)).attr('value') + '...' + $(e.get(0)).attr('value');
          } else {
            location.href = '@helpers.url(repository)/wiki/@helpers.urlEncode(pageName.get)/_compare/' +
              $(e.get(1)).attr('value') + '...' + $(e.get(0)).attr('value');
          }
        }
      });

      $('#top').click(function(){
        $('html,body').animate({ scrollTop: 0 }, 'fast');
      });
    });
    </script>
  }
}
